package com.wanxi.servlet.major;

import com.alibaba.fastjson.JSONObject;
import com.wanxi.dto.ResultDto;
import com.wanxi.model.MajorModel;
import com.wanxi.service.Impl.MajorServiceImpl;
import com.wanxi.service.MajorService;
import com.wanxi.util.Tool;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Li
 * @Date 2023/5/15 15:56
 */
@WebServlet("/back/FindMajorCount")
public class FindMajorCountServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //乱码处理
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");

        //调用service层
        MajorService majorService = new MajorServiceImpl();
        int resultDto = majorService.totalCount();
        //返回数据给前端
        resp.getWriter().println(JSONObject.toJSONString(resultDto));

    }
}
